package cn.ffcs.unm.views.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.stereotype.Repository;

import cn.ffcs.unm.views.dao.CostCenterDelDao;
import cn.ffcs.unm.views.model.CostCenter;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("costCenterDelDao")
public class CostCenterDelDaoImpl extends BaseDaoImpl implements
		CostCenterDelDao {

	@Override
	public PageInfo queryPageInfoByCostCenter(CostCenter costCenter,
			int currentPage, int pageSize) {
		StringBuilder sb = new StringBuilder();
		sb.append(" select * from vie_SYNC_COSTCENTER v where 1=1 ");
		List<Object> params = new ArrayList<Object>();
		if (null != costCenter) {
			if (!StrUtil.isEmpty(costCenter.getMonthId())) {
				sb.append(" AND v.monthId = ? ");
				params.add(costCenter.getMonthId());
			}
			if (!StrUtil.isEmpty(costCenter.getKostl())) {
				sb.append(" AND v.kostl LIKE ? ");
				params.add("%"
						+ StringEscapeUtils.escapeSql(costCenter.getKostl())
						+ "%");
			}
		}
		return this.jdbcFindPageInfo(sb.toString(), params, currentPage,
				pageSize, CostCenter.class);
	}

}
